package leetcode.editor.cn;

import org.junit.Assert;

public class P392IsSubsequence {
    public static void main(String[] args) {
        Solution solution = new P392IsSubsequence().new Solution();
        Assert.assertEquals(solution.isSubsequence("abc", "ahbgdc"), true);
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean isSubsequence(String s, String t) {
        char[] charsT = t.toCharArray();
        char[] charsS = s.toCharArray();
        int tIndex = 0, sIndex = 0;
        if (s.length() == 0) {
            return true;
        }
        while (tIndex < charsT.length&&sIndex<charsS.length) {
            char a = charsT[tIndex];
            char b = charsS[sIndex];
            if (a == b) {
                sIndex++;
            }
            tIndex++;
            if (sIndex == s.length()) {
                return true;
            }
        }
        return false;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}